package com.dalston.util;

import com.dalston.vo.UserVo;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;

/**
 * @author jh.pei
 * @date 2021/4/2 16:38
 */
public class UserPoneNumberSerializer extends StdSerializer<UserVo> {

    protected UserPoneNumberSerializer() {
        super(UserVo.class);
    }

    @Override
    public void serialize(UserVo userVo, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(hide(userVo.getPhoneNumber()));
    }
    public String hide(String s) {
        return s.substring(0,4)+"***";
    }
}
